package org.iabako.client.ui.page.business.sale;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.ui.HTMLPanel;
import org.iabako.client.config.page.PageEnum;
import org.iabako.client.navigation.NavigationController;
import org.iabako.client.ui.form.AbstractForm;
import org.iabako.client.ui.layout.field.IField;
import org.iabako.shared.entity.business.AbstractEntity;

import java.util.List;

/**
 * Created by jose on 06/07/15.
 */
public class SaleGoTo extends AbstractForm {

    interface MyUiBinder extends UiBinder<HTMLPanel, SaleGoTo> {
    }

    protected MyUiBinder binder = GWT.create(MyUiBinder.class);

    public SaleGoTo() {
        initWidget(binder.createAndBindUi(this));

        final String[] params = NavigationController.getInstance().getParams();

        //To remove last hashTag from URL
        NavigationController.getInstance().closePopups();

        if (params[0].contains("_draft_")) {
            params[0] = params[0].replace("_draft_", "");
            NavigationController.getInstance().goTo(PageEnum.SaleMake, this, params);
        } else {
            NavigationController.getInstance().goTo(PageEnum.SaleModify, null, params);
        }
    }


    @Override
    protected List<IField> getMandatoryFields() {
        return null;
    }

    @Override
    protected AbstractEntity getEntity() {
        return null;
    }

    @Override
    public boolean validate() {
        return false;
    }
}
